<?php 
$link=$player['link'];
$path=Yii::app()->params['tv_url_mb'];
$type=Yii::app()->params['tv_type_mb'];
$device=Tools::checkDevice();
if($device=='windowphone'){
	$path=Yii::app()->params['tv_url_wp'];
	$type=Yii::app()->params['tv_type_wp'];
}
elseif($device=='window'){
	$path=Yii::app()->params['tv_url_wp'];
	$type=Yii::app()->params['tv_type_wp'];
}
elseif($device=='android'){
	$path=Yii::app()->params['tv_url_android'];
	$type=Yii::app()->params['tv_type_android'];
}
elseif($device=='android2.1'){
	$path=Yii::app()->params['tv_url_android'];
	$type=Yii::app()->params['tv_type_android'];
}
elseif($device=='iphone'){
    $path=Yii::app()->params['tv_url_ios'];
	$type=Yii::app()->params['tv_type_ios'];
}
$tv=$path.$link.$type;
$html='';
if($device=='wap' || $device=='wp' || $device=='android2.1'){
			$html.= '<div style="text-align:center"><a class="player_video" href="'.$tv.'"><img src="images/Play_50-1.png"/><br/><img src="'.$player["icon"].'"/></a></div>';
}
else{
		$html.= '<video id="player1" width="100%" controls="controls" controls>';
					$html.= '<source src="'.$tv.'" type="video/mp4" />';
					$html.='</video>';
					if($device!='android'){
						$html.= '<script type="text/javascript">'.
						  'var player = new MediaElement("player1", {success: function(me) {'.
						    'me.play();'.
						    'me.addEventListener("timeupdate", function() {'.
						    'document.getElementById("time").innerHTML = me.currentTime;'.
							'}, false);'.
							'document.getElementById("pp")["onclick"] = function() {'.
							'if (me.paused){me.play();} else{me.pause();}};'.
						  '}});'.
						  'player.play();</script>';
					}
					else{
						$html.='<script type="text/javascript">'.
						'function init() {
					      enableVideoClicks();
					    }
					    function enableVideoClicks() {
					      var videos = document.getElementsByTagName("video") || [];
					      for (var i = 0; i < videos.length; i++) {
					        // TODO: use attachEvent in IE
					        videos[i].addEventListener("click", function(videoNode) {
					          return function() {
					            videoNode.play();
					          };
					        }(videos[i]));
					      }
					    }
					    init();
					    </script>';
					}
}
?>
<div class="tv_player"><?php echo $html;?></div>